package com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.entity.req.SmsEnrollmentManagementTaskReq;
import com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.service.SmsEnrollmentManagementTaskService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 招生计划表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-15
 */
@RestController
@RequestMapping("/enrollment/task")
@SecretBody
public class SmsEnrollmentManagementTaskController {
    @Resource
    private SmsEnrollmentManagementTaskService smsEnrollmentManagementTaskService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty(value = "添加招生计划")
    public ResponseResult addEnrollmentManagementTask(@RequestBody SmsEnrollmentManagementTaskReq taskReq, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEnrollmentManagementTaskService.addEnrollmentManagementTask(taskReq,user_id);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "删除招生计划")
    public ResponseResult deleteEnrollmentManagementTask(@RequestBody SmsEnrollmentManagementTaskReq taskReq, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEnrollmentManagementTaskService.deleteEnrollmentManagementTask(taskReq,user_id);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "修改招生计划")
    public ResponseResult updateEnrollmentManagementTask(@RequestBody SmsEnrollmentManagementTaskReq taskReq, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEnrollmentManagementTaskService.updateEnrollmentManagementTask(taskReq,user_id);
    }

    @PostMapping("/switch")
    @ApiModelProperty(value = "启用/关闭招生计划")
    public ResponseResult switchEnrollmentManagementTask(@RequestBody SmsEnrollmentManagementTaskReq taskReq){
        return smsEnrollmentManagementTaskService.switchEnrollmentManagementTask(taskReq);
    }


    @GetMapping("/list")
    @ApiModelProperty(value = "获取招生计划列表")
    public ResponseResult getEnrollmentManagementCollegeMajorList(@RequestParam(value = "searchStr",required = false) String searchStr,
                                                                  @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                  @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    ){
        return smsEnrollmentManagementTaskService.getEnrollmentManagementTaskList(searchStr,pageNum, pageSize);
    }

}

